package com.xyz.dao.dao;

import com.free.ext.mybatis.dao.BaseDao;
import com.free.ext.mybatis.model.entity.PageResponseModel;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xyz.dao.mapper.SAnnouncementMapper;
import com.xyz.domain.table.SAnnouncement;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import tk.mybatis.orderbyhelper.OrderByHelper;

import java.util.List;

@Repository
public class SAnnouncementDao extends BaseDao<SAnnouncement,Integer> {

    @Autowired
    private SAnnouncementMapper mapper;

    public List<SAnnouncement> getCustAnnounceInfo(SAnnouncement condition){
        return mapper.getCustAnnounceInfo(condition);
    }

    public PageResponseModel<SAnnouncement> selectByPageNo(SAnnouncement condition, String orderBy, int pageNo, int pageSize) {
        Page<SAnnouncement> lst = PageHelper.startPage(pageNo, pageSize);
        if (StringUtils.isNotEmpty(orderBy)) {
            OrderByHelper.orderBy(orderBy);
        }
        this.mapper.getCustAnnounceInfo(condition);
        return new PageResponseModel(lst);
    }
}